from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
from WMS_unittest.tools_unit import Tools
import unittest
import logging

class Wms(unittest.TestCase):
    def setUp(self) -> None:
        Tools().log1()
        self.driver = webdriver.Edge()
        self.driver.get('http://10.59.9.32/jeewms/loginController.do?login')
        self.driver.maximize_window()
        sleep(2)

    def tearDown(self) -> None:
        sleep(5)
        self.driver.quit()



    # 查询收货未上架
    def test_shouhuo(self):
        try:
            logging.info("*****************************************")
            # 每日检查-收货未上架
            sleep(5)
            self.driver.find_element(By.ID, 'but_login').click()
            sleep(2)
            self.driver.find_element(By.XPATH, '//*[@id="sidebar"]/ul/li[2]/a').click()
            sleep(2)
            self.driver.find_element(By.XPATH, '//*[@id="sidebar"]/ul/li[2]/ul/li[1]/a').click()
            sleep(2)
            self.driver.switch_to.frame(
                self.driver.find_element(By.XPATH, '//*[@id="tab_402881885f450361015f4752f3690065"]/iframe'))
            sleep(2)
            self.driver.find_element(By.NAME, 'bin_id').send_keys('1')
            self.driver.find_element(By.NAME, 'tin_id').send_keys('5')
            self.driver.find_element(By.NAME, 'cus_code').send_keys('5')
            self.driver.find_element(By.NAME, 'shp_ming_cheng').send_keys('原子弹')
            # 点击查询
            self.driver.find_element(By.XPATH, '//*[@id="wm_tuopanListtb"]/div[2]/span[2]/a[1]/span/span').click()
            sleep(2)
            dy = self.driver.find_element(By.XPATH,
                                           '/html/body/div/div[2]/div[2]/div[2]/div[1]/div/table/tbody/tr/td[1]/div/span[1]').text
            print(dy)
            self.assertEqual(dy, '库存状态')
            logging.info("*****************************************")
        except Exception as e:
            print(e)


if __name__ == '__main__':
    unittest.main()